package com.alamiya.security.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author hehaoqi
 * @since 2021-02-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_public_user")
@ApiModel(value = "PublicUser对象", description = "")
public class PublicUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户唯一标识")
    @TableId("ID")
    private String id;

    @ApiModelProperty(value = "用户名")
    @TableField("USERNAME")
    private String username;

    @ApiModelProperty(value = "密码")
    @TableField("PASSWORD")
    private String password;

    @ApiModelProperty(value = "电话号码")
    @TableField("PHONE_NUMBER")
    private String phoneNumber;

    @ApiModelProperty(value = "邮箱")
    @TableField("EMAIL")
    private String email;

    @ApiModelProperty(value = "微信ID")
    @TableField("WECHAT_ID")
    private String wechatId;

    @ApiModelProperty(value = "用户状态，0未启用，1启用")
    @TableField("USER_STATE")
    private Integer userState;

    @ApiModelProperty(value = "创建类型，0管理员创建，1注册")
    @TableField("CREATE_TYPE")
    private Integer createType;

    @ApiModelProperty(value = "操作人ID")
    @TableField("OPERATOR")
    private String operator;

    @ApiModelProperty(value = "用户头像文件地址")
    @TableField("PICTURE_PATH")
    private String picturePath;

    @ApiModelProperty(value = "创建时间")
    @TableField("CREATE_TIME")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新时间")
    @TableField("UPDATE_TIME")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "角色名称列表")
    @TableField(exist = false)
    private List<String> roleNames;

    public boolean isActivated() {
        if (userState == 1) {
            return true;
        }
        return false;
    }
}
